package java8stream;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ZhuQianli on 2018/1/17.
 */
public class Match {

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(i + 1);
        }

        // list中所有的都满足Predicate才返回true,反之list中有一个不满足Predicate就返回false
        Boolean allMatch = list.stream().allMatch(e -> e > 0);
        System.out.println(allMatch);

        // list中有一个满足Predicate就返回会true,反之list中没有一个满足Predicate才返回false
        Boolean anyMatch =  list.stream().anyMatch(e -> e == 2);
        System.out.println(anyMatch);

        // list中没有一个满足Predicate才返回true,反之list中有一个满足Predicate就返回false
        Boolean noneMatch = list.stream().noneMatch(e -> e < 0);
        System.out.println(noneMatch);

    }
}
